package com.wings4.school.student

class Religion {
    String religionName;
    String religionDescription;

    static constraints = {
        religionDescription(nullable: true);
    }
    public static void initialize() {
        def insertSql = [
                ["Islam","Religion Is Islam"],
                ["Hidu","Religion Is Hindu"],
                ["Cristan","Religion Is Cristan"]
        ]
        if (Religion.countByReligionName("Islam") < 1 && insertSql) {
            insertSql.each {
                Religion religion =null;
                try{
                    religion = new Religion(religionName: it[0], religionDescription: it[1]);
                    religion.save(flush: true);
                } catch(Exception e){
                    e.printStackTrace();
                }
            }

        }
        }
}
